package com.weyoung.app.controller;

import com.weyoung.app.dto.req.BiographyInsertEvenReqDTO;
import com.weyoung.app.dto.resp.BiographyEvenListDTO;
import com.weyoung.app.dto.resp.BiographyEventsListByFamilyDTO;
import com.weyoung.app.dto.resp.BiographyUserListByCountDTO;
import com.weyoung.app.dto.resp.BiographyUserListDTO;
import com.weyoung.app.service.BiographyService;
import com.weyoung.common.consatant.result.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/hall-fame")
@Slf4j
@RequiredArgsConstructor
@Tag(name = "名人堂相关接口")
public class BiographyController {
    private final BiographyService biographyService;

    /**
     * 获取名人堂用户列表及其事件列表
     *
     * @return Result
     */
    @GetMapping("/getUser")
    @Operation(summary = "获取名人堂用户列表")
    public Result<List<BiographyUserListDTO>> getUser() {
        return Result.success(biographyService.getBiographyUserListByUserId());
    }

    /**
     * 添加事件
     *
     * @param requestParam 请求参数·
     * @return Result
     * @throws Exception 异常
     */
    @PutMapping("addEvents")
    @Operation(summary = "添加事件")
    public Result<Void> addEvents(@ModelAttribute BiographyInsertEvenReqDTO requestParam) throws Exception {
        biographyService.addEvents(requestParam);
        return Result.success();
    }

    /**
     *  获取家族名人堂用户列表
     *
     * @return Result
     */
    @GetMapping("userList")
    @Operation(summary = "获取家族名人堂用户列表")
    public Result<List<BiographyUserListByCountDTO>> getUserList() {
        return Result.success(biographyService.getBiographyUserListByCount());
    }
       /**
     *  获取名人堂事件列表
     *
     * @return Result
     */
    @GetMapping("eventList")
    @Operation(summary = "获取名人堂事件列表")
    public Result<List<BiographyEventsListByFamilyDTO>> getEventList() {
        return Result.success(biographyService.getBiographyEventsListByFamily());
    }





}
 